const skinBehavior = require("../../../utils/themeSkin/skinBehavior")
var app = getApp();
Page({
  behaviors: [skinBehavior],

  /**
   * 页面的初始数据
   */
  data: {
    dy_password: '',
    show: false,
    details: {},
    type: "",
    popup_info:{},
    language: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    let details = wx.getStorageSync('tiktok_detail')
    let language = wx.getStorageSync('langIndex');
    this.setData({
      'language': language.en,
      details
    });
  },
  onClickHide() {
    this.setData({
      show: false
    })
  },
  code_link() {
    wx.setClipboardData({
      data: this.data.dy_password,
      success: () => {
        app.tips('口令已复制，打开抖音app下单！')
        this.setData({
          show: false
        })
      },
      fail: (err) => {
        app.tips('复制失败')
      }
    });
  },
  link(e) {
    let type = e.currentTarget.dataset.type;
    let item = e.currentTarget.dataset.item;
    let id = item.detail_url || item.author_openid;
    let json = {};
    let url = "";
    if(type == 'room'){
      url = 'plugin.tiktok-cps.api.live.tranfer-link';
      json.openid = id;
    }else{
      json.detail_url = id;
      url = 'plugin.tiktok-cps.api.goods.tranfer-link';
    }
    app._postNetWork({
      url: app.getNetAddresss(url),
      data: json,
      success: resdata => {
        if (resdata.data.result == 0) {
          return app.tips(resdata.data.msg);
        }
        this.setData({
          dy_password: resdata.data.data.dy_password,
          type,
          popup_info: item,
          show: true
        })
      }
    })


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})